Executed: Mon Mar 27 11:48:22 2017

Duration: 34 seconds.

Analysis of 5 smFRET samples

In this notebook:

  • Per-sample FRET histograms
  • Collapsed (merged channels) FRET histograms
  • FRET vs distance plot (multi-spot vs usALEX)
  • D-only fraction plots
  • Burst size vs measurement (corrected and uncorrected)
  • Background (per CH) vs measuremets
  • Burst-per-second (per CH) vs measuremet
  • Burst accumulation vs time (per CH and all-CH)

USAGE TIP: to comment-out a code cell, select all (CTRL+a) and hit CTRL+/.

FRET fitting remarks

In this notebook we fit the Proximity Ratio histogram using different models.

Load FRETBursts software


In [1]:
from fretbursts import *
sns = init_notebook()


 - Optimized (cython) burst search loaded.
 - Optimized (cython) photon counting loaded.
--------------------------------------------------------------
 You are running FRETBursts (version 0.5.9).

 If you use this software please cite the following paper:

   FRETBursts: An Open Source Toolkit for Analysis of Freely-Diffusing Single-Molecule FRET
   Ingargiola et al. (2016). http://dx.doi.org/10.1371/journal.pone.0160716 

--------------------------------------------------------------

In [2]:
import os
import pandas as pd
from IPython.display import display
from IPython.display import display, Math

In [3]:
import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed

In [4]:
import lmfit
print('lmfit version:', lmfit.__version__)


lmfit version: 0.9.5

8-spot paper plot style


In [5]:
PLOT_DIR = './figure/'

In [6]:
import matplotlib as mpl
from cycler import cycler

bmap = sns.color_palette("Set1", 9)
colors = np.array(bmap)[(1,0,2,3,4,8,6,7), :]
mpl.rcParams['axes.prop_cycle'] = cycler('color', colors)
colors_labels = ['blue', 'red', 'green', 'violet', 'orange', 'gray', 'brown', 'pink', ]
for c, cl in zip(colors, colors_labels):
    locals()[cl] = tuple(c) # assign variables with color names
sns.palplot(colors)


Data files

Data folder:


In [7]:
data_dir = './data/multispot/'

Check that the folder exists:


In [8]:
data_dir = os.path.abspath(data_dir) + '/'
assert os.path.exists(data_dir), "Path '%s' does not exist." % data_dir

List of data files in data_dir:


In [9]:
from glob import glob
file_list = sorted(glob(data_dir + '*.hdf5'))

In [10]:
labels = ['7d', '12d', '17d', '22d', '27d', 'DO']
files_dict = {lab: fname for lab, fname in zip(sorted(labels), file_list)}
files_dict


Out[10]:
{'12d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/12d_New_30p_320mW_steer_3.hdf5',
 '17d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/17d_100p_320mW_steer_1.hdf5',
 '22d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/22d_30p_320mW_steer_1.hdf5',
 '27d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/27d_50p_320mW_steer_1.hdf5',
 '7d': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/7d_New_150p_320mW_steer_3.hdf5',
 'DO': '/Users/anto/Google Drive/notebooks/multispot_paper/data/multispot/DO12_No2_50p_320mW_steer_1.hdf5'}

Parameters from file

Load the leakage coefficient from disk (computed in Multi-spot 5-Samples analyis - Leakage coefficient fit):


In [11]:
leakage_coeff_fname = 'results/Multi-spot - leakage coefficient KDE wmean DexDem.csv'
leakage = np.loadtxt(leakage_coeff_fname, ndmin=1)

print('Leakage coefficient:', leakage)


Leakage coefficient: [ 0.0334]

Load the direct excitation coefficient ($d_{dirT}$) from disk (computed in usALEX - Corrections - Direct excitation physical parameter):


In [12]:
dir_ex_coeff_fname = 'results/usALEX - direct excitation coefficient dir_ex_t beta.csv'
dir_ex_t = np.loadtxt(dir_ex_coeff_fname, ndmin=1)

print('Direct excitation coefficient (dir_ex_t):', dir_ex_t)


Direct excitation coefficient (dir_ex_t): [ 0.04932]

Parameters

Analysis parameters:


In [13]:
gamma_sel = 0.44     # Used to compute burst size during burst selection
donor_ref = False    # False -> gamma correction is: g*nd + na
                     # True  -> gamma correction is: nd + na/g

hist_weights = 'size'

## Background fit parameters
bg_kwargs_auto = dict(fun=bg.exp_fit,
                 time_s = 30,
                 tail_min_us = 'auto',
                 F_bg=1.7,
                 )

## Burst search
F=6
dither = False
size_th = 30    # Burst size threshold (selection on corrected burst sizes)

## FRET fit parameters
bandwidth = 0.03        # KDE bandwidth
E_range = {'7d':  (0.7, 1.0), '12d': (0.4, 0.8), '17d': (0.2, 0.4), 
           '22d': (0.0, 0.1), '27d': (0.0, 0.1), 'DO': (0.0, 0.1)}
E_axis_kde = np.arange(-0.2, 1.2, 0.0002)

Processing and plot options:


In [14]:
# Data load options
reload_data = 1
burst_search = 1
delete_ph_times = 0
# Plot output options save_figure = 0 nosuptitle = False plt.rc('savefig', dpi=75) # Changes the figure size in the notebook savefig_kwargs = dict(dpi=200, bbox_inches='tight') # default save-figure options fret_plot_kw = dict(bins = np.r_[-0.2:1.201:bandwidth], fit_color='k', fit_alpha=0.9, fit_lw=2, #fit_fillcolor='#888888', sharey = False)

Utility functions


In [15]:
def print_fit_report(E_pr, gamma=1, leakage=0, dir_ex_t=0, math=True):
    """Print fit and standard deviation for both corrected and uncorrected E
    Returns d.E_fit.
    """
    E_corr = fretmath.correct_E_gamma_leak_dir(E_pr, gamma=gamma, leakage=leakage, dir_ex_t=dir_ex_t)
    
    E_pr_mean = E_pr.mean()*100
    E_pr_delta = (E_pr.max() - E_pr.min())*100
    
    E_corr_mean = E_corr.mean()*100
    E_corr_delta = (E_corr.max() - E_corr.min())*100
    if math:
        display(Math(r'\text{Pre}\;\gamma\quad\langle{E}_{fit}\rangle = %.1f\%% \qquad'
                     '\Delta E_{fit} = %.2f \%%' % \
                     (E_pr_mean, E_pr_delta)))
        display(Math(r'\text{Post}\;\gamma\quad\langle{E}_{fit}\rangle = %.1f\%% \qquad'
                     '\Delta E_{fit} = %.2f \%%' % \
                     (E_corr_mean, E_corr_delta)))
    else:
        print('Pre-gamma  E (delta, mean):  %.2f  %.2f' % (E_pr_mean, E_pr_delta))
        print('Post-gamma E (delta, mean):  %.2f  %.2f' % (E_corr_mean, E_corr_delta))

5-samples processing


In [16]:
df = pd.DataFrame(index=['7d', '12d', '17d', '22d', '27d'], columns=range(8), dtype=float)
df.index.name = 'Sample'
df.columns.name = 'Channel'

E_pr_fret = df.copy()
E_pr_fret_sig = df.copy()
nbursts = df.copy()

7bp sample


In [17]:
data_id = '7d'
if reload_data:
    d7 = loader.photon_hdf5(files_dict[data_id])
    d7.calc_bg(**bg_kwargs_auto)
if burst_search:
    d7.burst_search(m=10, F=F, dither=dither)
    if delete_ph_times: d7.delete('ph_times_m')


 - Calculating BG rates ... [DONE]
 - Performing burst search (verbose=False) ...[DONE]
 - Calculating burst periods ...[DONE]
 - Counting D and A ph and calculating FRET ... 
   - Applying background correction.
   - Applying leakage correction.
   [DONE Counting D/A]

In [18]:
gamma_sel, donor_ref


Out[18]:
(0.44, False)

In [19]:
dfs7 = Sel(d7, select_bursts.size, th1=30, gamma=gamma_sel, donor_ref=donor_ref)
dx = dfs7

In [20]:
nbursts.loc[data_id] = dx.num_bursts

In [21]:
fitter = bext.bursts_fitter(dx)
fitter.histogram(bins=np.r_[-0.2 : 1.2 : bandwidth])
fitter.model = mfit.factory_two_gaussians(add_bridge=True, p2_center=0.8)
fitter.fit_histogram()

In [22]:
E_pr_fret.loc[data_id] = fitter.params['p2_center']
display(E_pr_fret.loc[[data_id]])
print_fit_report(E_pr_fret.loc[data_id], gamma=0.42, leakage=leakage, dir_ex_t=dir_ex_t)


Channel 0 1 2 3 4 5 6 7
Sample
7d 0.866766 0.872245 0.838805 0.84337 0.835858 0.858535 0.84036 0.846814
$$\text{Pre}\;\gamma\quad\langle{E}_{fit}\rangle = 85.0\% \qquad\Delta E_{fit} = 3.64 \%$$
$$\text{Post}\;\gamma\quad\langle{E}_{fit}\rangle = 92.7\% \qquad\Delta E_{fit} = 1.93 \%$$

In [23]:
dplot(dx, hist_fret, show_model=True, 
      show_fit_stats=True, fit_from='p2_center', show_fit_value=True);



In [24]:
fig, axes = plt.subplots(4, 2, figsize=(14, 12), sharex=True, sharey=True)
fig.subplots_adjust(left=0.08, right=0.96, top=0.93, bottom=0.07,
                    wspace=0.06, hspace=0.15)

for ich, ax in enumerate(axes.ravel()):
    mfit.plot_mfit(fitter, ich=ich, ax=ax)


Compare the effect of burst-size weights


In [25]:
# bext.bursts_fitter(dx, weights=None)
# dx.E_fitter.fit_histogram(mfit.factory_two_gaussians())
# dplot(dx, hist_fret, weights=None, show_model=True, show_fit_stats=True, fit_from='p2_center');
# ylim(0, 6)
# fig_no_w = gcf()
# plt.close(fig_no_w)

# bext.bursts_fitter(dx, weights='size', gamma=0.43)
# dx.E_fitter.fit_histogram(mfit.factory_two_gaussians())
# dplot(dx, hist_fret, weights='size', gamma=0.43,
#       show_model=True, show_fit_stats=True, fit_from='p2_center');
# fig_w = gcf()
# plt.close(fig_w)

# def _plot(weights=False):
#     if weights:
#         display(fig_w)
#     else:
#         display(fig_no_w)

# interact(_plot, weights=False);

12bp sample


In [26]:
data_id = '12d'
if reload_data: 
    d12 = loader.photon_hdf5(files_dict[data_id])
    d12.calc_bg_cache(**bg_kwargs_auto)
if burst_search:
    d12.burst_search(m=10, F=F, dither=dither)
    if delete_ph_times: d12.delete('ph_times_m')


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]
 - Performing burst search (verbose=False) ...[DONE]
 - Calculating burst periods ...[DONE]
 - Counting D and A ph and calculating FRET ... 
   - Applying background correction.
   - Applying leakage correction.
   [DONE Counting D/A]

In [27]:
dfs12 = Sel(d12, select_bursts.size, th1=30, gamma=gamma_sel, donor_ref=donor_ref)
dx = dfs12

In [28]:
nbursts.loc[data_id] = dx.num_bursts

In [29]:
fitter = bext.bursts_fitter(dx)
fitter.histogram(bins=np.r_[-0.2 : 1.2 : bandwidth])
fitter.model = mfit.factory_two_gaussians(add_bridge=True, p2_center=0.65)
fitter.fit_histogram()
E_pr_fret.loc[data_id] = fitter.params['p2_center']
display(E_pr_fret.loc[[data_id]])
print_fit_report(E_pr_fret.loc[data_id], gamma=0.42, leakage=leakage, dir_ex_t=dir_ex_t)


Channel 0 1 2 3 4 5 6 7
Sample
12d 0.58912 0.580325 0.572867 0.574415 0.563134 0.555029 0.565811 0.563246
$$\text{Pre}\;\gamma\quad\langle{E}_{fit}\rangle = 57.0\% \qquad\Delta E_{fit} = 3.41 \%$$
$$\text{Post}\;\gamma\quad\langle{E}_{fit}\rangle = 74.3\% \qquad\Delta E_{fit} = 2.76 \%$$

In [30]:
dplot(dx, hist_fret, show_model=True, 
      show_fit_stats=True, fit_from='p2_center', show_fit_value=True);


17bp sample


In [31]:
data_id = '17d'
if reload_data:
    d17 = loader.photon_hdf5(files_dict[data_id])
    d17.calc_bg_cache(**bg_kwargs_auto)
if burst_search:
    d17.burst_search(m=10, F=F, dither=dither)
    if delete_ph_times: d17.delete('ph_times_m')


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]
 - Performing burst search (verbose=False) ...[DONE]
 - Calculating burst periods ...[DONE]
 - Counting D and A ph and calculating FRET ... 
   - Applying background correction.
   - Applying leakage correction.
   [DONE Counting D/A]

In [32]:
dfs17 = Sel(d17, select_bursts.size, th1=30, gamma=gamma_sel, donor_ref=donor_ref)
dx = dfs17

In [33]:
nbursts.loc[data_id] = dx.num_bursts

In [34]:
fitter = bext.bursts_fitter(dx)
fitter.histogram(bins=np.r_[-0.2 : 1.2 : bandwidth])
fitter.model = mfit.factory_two_gaussians(add_bridge=False, p2_center=0.4)
fitter.fit_histogram()
E_pr_fret.loc[data_id] = fitter.params['p2_center']
display(E_pr_fret.loc[[data_id]])
print_fit_report(E_pr_fret.loc[data_id], gamma=0.42, leakage=leakage, dir_ex_t=dir_ex_t)


Channel 0 1 2 3 4 5 6 7
Sample
17d 0.297846 0.287886 0.276148 0.279504 0.283104 0.284872 0.271156 0.271861
$$\text{Pre}\;\gamma\quad\langle{E}_{fit}\rangle = 28.2\% \qquad\Delta E_{fit} = 2.67 \%$$
$$\text{Post}\;\gamma\quad\langle{E}_{fit}\rangle = 43.4\% \qquad\Delta E_{fit} = 3.74 \%$$

In [35]:
dplot(dx, hist_fret, show_model=True, 
      show_fit_stats=True, fit_from='p2_center', show_fit_value=True);


22bp sample


In [36]:
data_id = '22d'
if reload_data:
    d22 = loader.photon_hdf5(files_dict[data_id])
    d22.calc_bg_cache(**bg_kwargs_auto)
if burst_search:
    d22.burst_search(m=10, F=F, dither=dither)
    if delete_ph_times: d22.delete('ph_times_m')


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]
 - Performing burst search (verbose=False) ...[DONE]
 - Calculating burst periods ...[DONE]
 - Counting D and A ph and calculating FRET ... 
   - Applying background correction.
   - Applying leakage correction.
   [DONE Counting D/A]

In [37]:
dfs22 = Sel(d22, select_bursts.size, th1=30, gamma=gamma_sel, donor_ref=donor_ref)
dx = dfs22

In [38]:
nbursts.loc[data_id] = dx.num_bursts

In [39]:
fitter = bext.bursts_fitter(dx)
fitter.histogram(bins=np.r_[-0.2 : 1.2 : bandwidth])
fitter.model = mfit.factory_gaussian()
fitter.fit_histogram()
E_pr_fret.loc[data_id] = fitter.params['center']
display(E_pr_fret.loc[[data_id]])
print_fit_report(E_pr_fret.loc[data_id], gamma=0.42, leakage=leakage, dir_ex_t=dir_ex_t)


Channel 0 1 2 3 4 5 6 7
Sample
22d 0.133968 0.131691 0.124933 0.126694 0.119514 0.124942 0.122458 0.12983
$$\text{Pre}\;\gamma\quad\langle{E}_{fit}\rangle = 12.7\% \qquad\Delta E_{fit} = 1.45 \%$$
$$\text{Post}\;\gamma\quad\langle{E}_{fit}\rangle = 17.1\% \qquad\Delta E_{fit} = 2.95 \%$$

In [40]:
dplot(dx, hist_fret, show_model=True, 
      show_fit_stats=True, fit_from='center', show_fit_value=True);


27bp sample


In [41]:
data_id = '27d'
if reload_data:
    d27 = loader.photon_hdf5(files_dict[data_id])
    d27.calc_bg_cache(**bg_kwargs_auto)
if burst_search:
    d27.burst_search(m=10, F=F, dither=dither)#, ph_sel=Ph_sel(Dex='Dem'))
    if delete_ph_times: d27.delete('ph_times_m')


 * No cached BG rates, recomputing:
 - Calculating BG rates ... [DONE]
 - Performing burst search (verbose=False) ...[DONE]
 - Calculating burst periods ...[DONE]
 - Counting D and A ph and calculating FRET ... 
   - Applying background correction.
   - Applying leakage correction.
   [DONE Counting D/A]

In [42]:
dfs27 = Sel(d27, select_bursts.size, th1=30, gamma=gamma_sel, donor_ref=donor_ref)
dx = dfs27

In [43]:
nbursts.loc[data_id] = dx.num_bursts

In [44]:
fitter = bext.bursts_fitter(dx)
fitter.histogram(bins=np.r_[-0.2 : 1.2 : bandwidth])
fitter.model = mfit.factory_asym_gaussian()
fitter.fit_histogram()
E_pr_fret.loc[data_id] = fitter.params['center']
display(E_pr_fret.loc[[data_id]])
print_fit_report(E_pr_fret.loc[data_id], gamma=0.42, leakage=leakage, dir_ex_t=dir_ex_t)


Channel 0 1 2 3 4 5 6 7
Sample
27d 0.078874 0.073995 0.073122 0.079337 0.071889 0.073837 0.073261 0.081081
$$\text{Pre}\;\gamma\quad\langle{E}_{fit}\rangle = 7.6\% \qquad\Delta E_{fit} = 0.92 \%$$
$$\text{Post}\;\gamma\quad\langle{E}_{fit}\rangle = 5.9\% \qquad\Delta E_{fit} = 2.16 \%$$

In [45]:
dplot(dx, hist_fret, show_model=True, 
      show_fit_stats=True, fit_from='center', show_fit_value=True);



In [46]:
fitter = bext.bursts_fitter(dx)
fitter.histogram(bins=np.r_[-0.2 : 1.2 : bandwidth])
fitter.model = mfit.factory_gaussian()
fitter.fit_histogram()
E_pr_fret.loc[data_id] = fitter.params['center']
display(E_pr_fret.loc[[data_id]])
print_fit_report(E_pr_fret.loc[data_id], gamma=0.42, leakage=leakage, dir_ex_t=dir_ex_t)


Channel 0 1 2 3 4 5 6 7
Sample
27d 0.087183 0.091312 0.079124 0.08268 0.077164 0.084574 0.077923 0.082638
$$\text{Pre}\;\gamma\quad\langle{E}_{fit}\rangle = 8.3\% \qquad\Delta E_{fit} = 1.41 \%$$
$$\text{Post}\;\gamma\quad\langle{E}_{fit}\rangle = 7.6\% \qquad\Delta E_{fit} = 3.25 \%$$

In [47]:
dplot(dx, hist_fret, show_model=True, 
      show_fit_stats=True, fit_from='center', show_fit_value=True);


5-samples: global analysis

Proximity ratios fitted from multispot data:


In [48]:
E_pr_fret = E_pr_fret.round(6)
E_pr_fret


Out[48]:
Channel 0 1 2 3 4 5 6 7
Sample
7d 0.866766 0.872245 0.838805 0.843370 0.835858 0.858535 0.840360 0.846814
12d 0.589120 0.580325 0.572867 0.574415 0.563134 0.555029 0.565811 0.563246
17d 0.297846 0.287886 0.276148 0.279504 0.283104 0.284872 0.271156 0.271861
22d 0.133968 0.131691 0.124933 0.126694 0.119514 0.124942 0.122458 0.129830
27d 0.087183 0.091312 0.079124 0.082680 0.077164 0.084574 0.077923 0.082638

In [49]:
nbursts = nbursts.astype(int)
nbursts


Out[49]:
Channel 0 1 2 3 4 5 6 7
Sample
7d 953 363 1018 1543 1413 656 1648 1844
12d 926 576 1112 1474 1349 824 1510 1575
17d 740 493 778 1026 1005 642 1066 1160
22d 322 251 354 495 354 282 438 470
27d 630 430 736 910 933 619 933 1039

In [50]:
E_pr_fret.to_csv('results/Multi-spot - dsDNA - PR - all_samples all_ch.csv')
nbursts.to_csv('results/Multi-spot - dsDNA - nbursts - all_samples all_ch.csv')

In [51]:
norm = (E_pr_fret.T - E_pr_fret.mean(1))#/E_pr_fret.mean(1)
norm_rel = (E_pr_fret.T - E_pr_fret.mean(1))/E_pr_fret.mean(1)
norm.plot()
norm_rel.plot()


Out[51]:
<matplotlib.axes._subplots.AxesSubplot at 0x1393dfac8>

In [52]:
mch_plot_bg(dx)


NOTE: The 27d and DO samples have a trend that correlates with the A-ch background. For these samples could be beneficial to use a D-only burst search.

NOTE 2: Like observed during the leakage fit, even a D-only burst search results in +2% offset (DO) in CH1, this cannot be correlation with the A-background and must be slightly different gamma in the spot.

Corrected $E$ from μs-ALEX data:


In [53]:
data_file = 'results/usALEX-5samples-E-corrected-all-ph.csv'
data_alex = pd.read_csv(data_file).set_index('sample')#[['E_pr_fret_kde']]
data_alex.round(6)


Out[53]:
n_bursts_all n_bursts_do n_bursts_fret E_kde_w E_gauss_w E_gauss_w_sig E_gauss_w_err E_gauss_w_fiterr S_kde S_gauss S_gauss_sig S_gauss_err S_gauss_fiterr E_pr_do_kde nt_mean
sample
7d 1172 587 542 0.9290 0.924307 0.060130 0.002583 0.001782 0.5520 0.550744 0.099172 0.004260 0.002501 0.0022 22.227823
12d 1307 329 948 0.7398 0.727043 0.092062 0.002990 0.001995 0.5758 0.558745 0.105387 0.003423 0.003823 0.0154 22.002399
17d 2489 464 1964 0.4268 0.422624 0.112952 0.002549 0.002008 0.5462 0.539604 0.112457 0.002538 0.002187 0.0124 21.193171
22d 2054 320 1672 0.1774 0.181067 0.077181 0.001888 0.001536 0.5458 0.547034 0.114990 0.002812 0.002676 0.0000 23.016538
27d 791 160 589 0.0826 0.083971 0.069303 0.002856 0.001585 0.5208 0.561290 0.114456 0.004716 0.003679 -0.0088 16.830070

In [54]:
E_alex = data_alex.E_gauss_w
E_alex


Out[54]:
sample
7d     0.924307
12d    0.727043
17d    0.422624
22d    0.181067
27d    0.083971
Name: E_gauss_w, dtype: float64

Merging the channels

Merge the data of the different channels:


In [55]:
dfs7c = dfs7.collapse()
dfs12c = dfs12.collapse()
dfs17c = dfs17.collapse()
dfs22c = dfs22.collapse()
dfs27c = dfs27.collapse()

Define samples lists

Define list of results and labels:


In [56]:
d_samples = [dfs7, dfs12, dfs17, dfs22, dfs27]#, dfso]
d_samples_c = [dfs7c, dfs12c, dfs17c, dfs22c, dfs27c ]
d_labels = ['7d', '12d', '17d', '22d', '27d']#, 'DO']
CH = np.arange(8)
CH_labels = ['CH%d' % i for i in CH]
dist_s_bp = [7, 12, 17, 22, 27]

Print a summary of current processed data:


In [57]:
def print_params(d_samples, d_labels, status=False):
    print('Sample              Model             Ph_sel')
    for dx, name in zip(d_samples, d_labels):
        print("%3s %25s %35s" % (name, dx.E_fitter.model.name, dx.ph_sel))
    if status:
        print()
        for dx, name in zip(d_samples, d_labels):
            print(dx.status())

In [58]:
print_params(d_samples, d_labels, 1)


Sample              Model             Ph_sel
 7d ((Model(gaussian, prefix='p1_') + Model(gaussian, prefix='p2_')) + Model(bridge_function, prefix='br_'))                                 all
12d ((Model(gaussian, prefix='p1_') + Model(gaussian, prefix='p2_')) + Model(bridge_function, prefix='br_'))                                 all
17d (Model(gaussian, prefix='p1_') + Model(gaussian, prefix='p2_'))                                 all
22d           Model(gaussian)                                 all
27d           Model(gaussian)                                 all

multispot_7d_New_150p_320mW_steer_3 BS_all L10 m10 MR44 G1.000 BGexp-30s bg Lk0.000size_th30Ga_0.4
multispot_12d_New_30p_320mW_steer_3 BS_all L10 m10 MR36 G1.000 BGexp-30s bg Lk0.000size_th30Ga_0.4
multispot_17d_100p_320mW_steer_1 BS_all L10 m10 MR41 G1.000 BGexp-30s bg Lk0.000size_th30Ga_0.4
multispot_22d_30p_320mW_steer_1 BS_all L10 m10 MR37 G1.000 BGexp-30s bg Lk0.000size_th30Ga_0.4
multispot_27d_50p_320mW_steer_1 BS_all L10 m10 MR40 G1.000 BGexp-30s bg Lk0.000size_th30Ga_0.4

Plot FRET vs distance

fontsize = 12 text_pos = {'7d': (10.5, 0.92), '12d': (15.5, 0.74), '17d': (16, 0.43), '22d': (21, 0.18), '27d': (29, 0.15)} text_kwargs = dict(ha='right', va='center', bbox=dict(facecolor='white', edgecolor='white'), zorder=2, fontsize=fontsize-1, ) dfun = lambda E_fit: 100*(E_fit.max()-E_fit.min()) fig, ax = plt.subplots() ax.plot(dist_s_bp, E_fret_mch, '+', lw=2, mew=1.2, ms=8, zorder=4) ax.plot(dist_s_bp, E_alex, '-', lw=3, mew=0, alpha=0.5, color='r', zorder=3) plt.title('Multi-spot smFRET dsDNA, Gamma = %.2f' % multispot_gamma) plt.xlabel('Distance in base-pairs', fontsize=fontsize); plt.ylabel('E', fontsize=fontsize) plt.ylim(0, 1); plt.xlim(0, 30) plt.grid(True) plt.legend(['CH1','CH2','CH3','CH4','CH5','CH6','CH7','CH8', u'μsALEX'], fancybox=True, prop={'size':fontsize-1}, #loc='upper right', bbox_to_anchor=(1.05, 1)) loc='best') if deviance_plot: for sample in E_fret_mch.index: delta = dfun(E_fret_mch.loc[sample]) text_kwargs.update( s="%.1f%%" % delta, #s="$\Delta = %.1f%%$" % delta, x=text_pos[sample][0], y=text_pos[sample][1], ) ax.text(**text_kwargs) #ax.set_axisbelow(True) #if save_figure: plt.savefig("FRET vs distance - %s SPW F%d.png" % (fret_gen_fit_func.__name__, F)) #plt.savefig(PLOT_DIR+"FRET vs distance - Gpost_th30.png", dpi=200, bbox_inches='tight')